<?php
namespace app\json\controller;

use think\Db;
class Reg extends Controller
{
    //注册
   
    public function applyvip($uname,$uuname,$upw,$uphone,$uemail,$ugender,$upic,$uage)
    {
        $data=[
            'uname'=>$uname,
            'uuname'=>$uuname,
            'upw'=>md5(input('upw')),
            'uphone'=>$uphone,
            'uemail'=>$uemail,
            'ugender'=>$ugender,
            'upic'=>$upic,
            'uage'=>$uage,
            'useraddtime'=>date('Y-m-d H:i:s'),
            'ustatus'=>1,
        ];
        // dump($data);
        // exit;
        
        if(Db::name('user')->insert($data)){
            return json(['code'=>1]);
        }
        else{
            return json(['code'=>0]); 
        }
    } 
    //登录
    public function login($uname,$upw)
    {
        $data=[
            'uname'=>$uname,
            'upw'=>md5(input('upw')),
            
        ];
        // dump($data);
        // exit;
        $res=Db::name('user')->where($data)->find();
        if($res){
            return json(['code'=>1]);
        }
        else{
            return json(['code'=>0]); 
        }
    }

    public function test(){
        return 1;
    }
}